#include "GLGroup.h"


CGLGroup::CGLGroup(void)
{
	for (int32_t i = 0; i != GroupCount; ++i)
		m_Members[i] = nullptr;
}


CGLGroup::~CGLGroup(void)
{
	for (int32_t i = 0; i != GroupCount; ++i) {
	AnimalLookInfo* tInfo = m_Members[i];
	if (nullptr != tInfo) {
		delete tInfo;
	}
}
}

bool CGLGroup::Add(const AnimalLookInfo& info) {
	bool tFull = false;
	for (int32_t i = 0; i != GroupCount; ++i) {
		AnimalLookInfo* tInfo = m_Members[i];
		if (nullptr == tInfo) {
			tInfo = new AnimalLookInfo;
			*tInfo = info;
			m_Members[i] = tInfo;

			if (i == GroupCount - 1)
				tFull = true;
			break;
		}
	}
	return tFull;
}

bool CGLGroup::Rem(const AnimalLookInfo& info) {
	bool tInvalid = false;
	for (int32_t i = 0; i != GroupCount; ++i) {
		AnimalLookInfo* tInfo = m_Members[i];
		if (nullptr != tInfo) {
			if (tInfo->m_Uid == info.m_Uid && tInfo->m_Type == info.m_Type) {
				delete tInfo;
				m_Members[i] = nullptr;

				if (i == GroupDuizhang)
					tInvalid = true;
			}
		}
	}

	return tInvalid;
}

bool CGLGroup::Rem(const uint64_t& uid) {
	bool tInvalid = false;
	for (int32_t i = 0; i != GroupCount; ++i) {
		AnimalLookInfo* tInfo = m_Members[i];
		if (nullptr != tInfo) {
			if (tInfo->m_Uid == uid) {
				delete tInfo;
				m_Members[i] = nullptr;

				if (i == GroupDuizhang)
					tInvalid = true;
			}
		}
	}

	return tInvalid;
}
